package com.keyancompany.zhongbaopingtai.api;

import android.util.Log;

import com.keyancompany.zhongbaopingtai.ConstansUrl;
import com.keyancompany.zhongbaopingtai.ZBApplication;
import com.keyancompany.zhongbaopingtai.listener.IAsyncHttpResponseHandler;
import com.keyancompany.zhongbaopingtai.listener.LoadingHanlder;
import com.keyancompany.zhongbaopingtai.utils.AppUtils;
import com.loopj.android.http.RequestParams;

import java.io.File;
import java.io.FileNotFoundException;

/**
 * Created by Gia on 2016/10/10.
 */
public class FileAPI extends BaseAPI {

    public static final int UPLOAD_FILE = 0X711;


    /**
     * 上传文件
     * <p/>
     * //     * @param userId:用户代码
     */
    public static final void uploadFile(File file,
                                        IAsyncHttpResponseHandler handler, LoadingHanlder loading) {

        Log.e("hpt", "file.exist " + file.exists());
        RequestParams params = new RequestParams();
        params.put("userId", UserAPI.getUserId());
        try {
            params.put("Filedata", file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }

        uploadFile(ConstansUrl.UPLOAD, params, handler, UPLOAD_FILE, loading);
    }

}
